package com.click.app;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.Date;
/**
 * @author Joel Chuca Condo
 * @date 16/04/2009
 */
public class DateFormatChanger { 

    public static String changeDatetoString(Date date) {
        if (date != null){
            SimpleDateFormat formatoDeFecha = new SimpleDateFormat("dd/MM/yyyy");
            return formatoDeFecha.format(date);
        }
        return null;
    }

    public static Date changeStringtoDate(String dateString) {
        
        Date date = null;

        try {
            SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
            date = formatter.parse(dateString);            
        } catch (ParseException ex) {
            System.out.println("The param date string does't have format requerid");
            //ex.printStackTrace();
            return null;
        } catch (NullPointerException e){
            System.out.println("The param date string is null");
            //e.printStackTrace();
            return null;
        }
        return date;
    }
/*
    public static void main(String[] a){
        DateFormatChanger changer = new DateFormatChanger();
        System.out.println(changer.changeStringtoDate("30/04/2009"));
    }*/
}
